home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: Help with Bug Pleeeeease!
- Date: 29 Jan 1996 15:18:40 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4eiogg$cbj@dawn.mmm.com>
- References: <tday-2801961838030001@tday.slip.netcom.com>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Tony Day (tday@netcom.com) wrote:
-
- [ explanation and lots of code elided ]
-
- > String String::operator+(const String & st) const
- > {
- > String temp1;
- > delete [] temp1.str;
- > temp1.len = st.len+len;
- > temp1.str = new char[temp1.len+1];
- > strcpy(temp1.str,str);
- > for (int i=len; i< temp1.len; i++)
- > temp1.str[i]=st.str[i-len];
- > temp1.str[temp1.len+1]='\0';
- ^^ <-- The bug is here. Leave off the +1.
- > cout << temp1.len << " length1st\n";
- > return temp1;
- > }
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-